import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

ApplicationWindow {
    visible: true
    width: 400
    height: 300
    title: "TreeView Example"

    // 定义一个简单的列表模型
    ListModel {
        id: listModel
        ListElement { name: "Item 1"; value: 10 }
        ListElement { name: "Item 2"; value: 20 }
        ListElement { name: "Item 3"; value: 30 }
        ListElement { name: "Item 4"; value: 40 }
    }

    // 定义 TreeView
    TreeView {
        id: treeView
        anchors.fill: parent
        model: listModel
        columnSpacing: 10

        // 定义 TreeView 的列
        delegate: RowLayout {
            width: parent.width
            height: 40
            spacing: 10

            Text {
                text: model.name
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignLeft
            }

            Text {
                text: model.value
                Layout.fillWidth: true
                Layout.alignment: Qt.AlignRight
            }
        }

    }
}
